﻿using System;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WP7Guide
{
    public class LogoConverter:IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var refId = value as string;
            if (!string.IsNullOrEmpty(refId))
            {
                refId = refId.Replace(":", "_").TrimEnd('_');
                BitmapImage img = new BitmapImage(new Uri("picon/picon/png/" + refId + ".png", UriKind.Relative));
#if DEBUG

                img.ImageOpened += new EventHandler<RoutedEventArgs>(img_ImageOpened);
#endif
                return img;
            }
            return null;
        }

        void img_ImageOpened(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("Img: " + ((BitmapImage)sender).UriSource.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
